//
//  BorrowOrInvestCell.m
//  WBBaseProject
//
//  Created by 吴斌 on 2018/3/5.
//  Copyright © 2018年 吴斌. All rights reserved.
//

#import "BorrowOrInvestCell.h"
#import "InvestOrBorrowView.h"

@implementation BorrowOrInvestCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setUpUI];
    }
    return self;
}

- (void)setUpUI
{
    UIView *line = [[UIView alloc] init];
    line.backgroundColor = WB_RGBColor(229, 229, 229);
    [self.contentView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(-5);
        make.width.equalTo(0.5);
        make.height.equalTo(40);
    }];
    
    InvestOrBorrowView *borrowView = [[NSBundle mainBundle] loadNibNamed:@"InvestOrBorrowView" owner:nil options:nil].firstObject;
    borrowView.tag = 1000;
    borrowView.titleLb.text = @"我要借贷";
    borrowView.iconIV.image = WB_ImageName(@"我要借贷");
    borrowView.detailLb.text = @"最高可借30,000元";
    [self.contentView addSubview:borrowView];
    [borrowView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.bottom.equalTo(0);
        make.right.equalTo(line.left).equalTo(0);
    }];
    UITapGestureRecognizer *borrowTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click:)];
    [borrowView addGestureRecognizer:borrowTap];
    
    InvestOrBorrowView *investView = [[NSBundle mainBundle] loadNibNamed:@"InvestOrBorrowView" owner:nil options:nil].firstObject;
    investView.tag = 1001;
    investView.titleLb.text = @"我要投资";
    investView.iconIV.image = WB_ImageName(@"我要投资");
    investView.detailLb.text = @"年华收益7-24%";
    [self.contentView addSubview:investView];
    [investView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.top.bottom.equalTo(0);
        make.left.equalTo(line.right).equalTo(0);
    }];
    UITapGestureRecognizer *investTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click:)];
    [investView addGestureRecognizer:investTap];
}

- (void)click:(UITapGestureRecognizer *)tag{
    UIView *view = tag.view;
    if (self.clickMethod) {
        self.clickMethod(view);
    }
}

@end
